package com.itools.core.service.impl;

import com.itools.core.param.FmsUploadTokenParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.concurrent.Callable;

/**
 * @description:
 * @author: XUCHANG
 * @create: 2021-03-28 15:51
 */
public class FmsFileRecordUploadTask implements Callable<String> {
    /**
     * 自身实现
     */
    private FmsFileSystemServiceImpl self;
    /**
     * 上传的文件
     */
    private MultipartFile file;
    /**
     * 文件的访问的token获取的信息
     */
    private FmsUploadTokenParam param;
    /**
     * 生成的UUID
     */
    private String uuid;

    public FmsFileRecordUploadTask(FmsFileSystemServiceImpl self, MultipartFile file, FmsUploadTokenParam param, String uuid) {
        this.self = self;
        this.file = file;
        this.param = param;
        this.uuid = uuid;
    }

    @Override
    public String call() {
        try {
            String file = self.saveFile(this.file, param, uuid);
            return file;
        }catch (Exception e){
            return null;
        }
    }

}
